package sskj.regulatory.presentation.base_mvp.base

import android.os.Bundle
import android.support.annotation.CallSuper
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import com.qmuiteam.qmui.widget.dialog.QMUIDialog
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog
import sskj.regulatory.App
import sskj.regulatory.arch.BaseMVPActivity
import sskj.regulatory.di.component.ActivityComponent
import sskj.regulatory.di.module.ActivityModule
import sskj.regulatory.ribble.presentation.utils.extensions.unSafeLazy
import javax.inject.Inject


abstract class BaseActivity<V : BaseContract.View, P : BaseContract.Presenter<V>>
    : BaseMVPActivity<V, P>(), BaseContract.View {


    @Inject
    lateinit var inflater: LayoutInflater

    private var dialog: QMUIDialog? = null

    var tipDialog: QMUITipDialog? = null


    val activityComponent: ActivityComponent by unSafeLazy {
        getAppComponent() + ActivityModule(this)
    }

    @CallSuper
    override fun onCreate(savedInstanceState: Bundle?) {
        injectDependencies()
        super.onCreate(savedInstanceState)
    }

    @CallSuper
    override fun onDestroy() {
        dialog?.dismiss()
        super.onDestroy()
    }

    protected abstract fun injectDependencies()

    private fun getAppComponent() = App.instance.applicationComponent

    override fun sessionError() {

    }

    override fun connectError() {

    }

}